import type { FC } from 'react';
import BaseLayout from '@/layout/Index'
import Login from '@/views/login/Index'
import { Navigate, Route, Routes } from 'react-router-dom';
import { useAppSelector } from './store/hooks';
import store2 from 'store2';

interface AppProps { }

const App: FC<AppProps> = () => {
  const adminname = useAppSelector(state => state.admin.adminname)
  const url = store2.session.get('pathname')
  return (
    <Routes>
       <Route path='/login' element={adminname? <Navigate to={url ? url : '/'} /> : <Login />}></Route>
       <Route path='/*' element={adminname? <BaseLayout /> : <Navigate to='/login' />  }></Route>
    </Routes>
  );
}
export default App;
